import request from '../utils/request';
import type { ChatParams, ChatResponse, ChatHistory } from '../types/chat';

// 发送聊天消息
export const sendChatMessage = async (params: ChatParams): Promise<ChatResponse> => {
  const response = await request({
    url: '/chat/send',
    method: 'post',
    data: params
  });
  return response;
};

// 获取历史对话列表
export const getChatHistory = async (): Promise<ChatResponse<ChatHistory[]>> => {
  const response = await request({
    url: '/chat/history',
    method: 'get'
  });
  return response;
};

// 获取单个历史对话详情
export const getChatDetail = async (chatId: string): Promise<ChatResponse<ChatHistory>> => {
  const response = await request({
    url: `/chat/detail/${chatId}`,
    method: 'get'
  });
  return response;
};

// 删除历史对话
export const deleteChatHistory = async (chatId: string): Promise<ChatResponse<void>> => {
  const response = await request({
    url: `/chat/delete/${chatId}`,
    method: 'delete'
  });
  return response;
};

// 清空所有历史对话
export const clearAllHistory = async (): Promise<ChatResponse<void>> => {
  const response = await request({
    url: '/chat/clear',
    method: 'delete'
  });
  return response;
};

import api from './api';

export interface ChatParams {
  question: string;
}

// OpenAI相关API
export const openaiChat = (params: ChatParams) => {
  return api.post('/openai/chat', params);
};

export const openaiDraw = (params: ChatParams) => {
  return api.post('/openai/draw', params);
};

export const getOpenAIChatHistory = () => {
  return api.post('/openai/getchatlist');
};

export const getOpenAIDrawHistory = () => {
  return api.post('/openai/getdrawlist');
};

// 通义千问相关API
export const tongyiChat = (params: ChatParams) => {
  return api.post('/tongyi/chat', params);
};

export const tongyiDraw = (params: ChatParams) => {
  return api.post('/tongyi/draw', params);
};

// 讯飞星火相关API
export const xunfeiChat = (params: ChatParams) => {
  return api.post('/xunfei/chat', params);
};

export const xunfeiDraw = (params: ChatParams) => {
  return api.post('/xunfei/draw', params);
};

// 文心一言相关API
export const qianfanChat = (params: ChatParams) => {
  return api.post('/qianfan/chat', params);
};

export const qianfanDraw = (params: ChatParams) => {
  return api.post('/qianfan/draw', params);
};

// 豆包相关API
export const doubaoChat = (params: ChatParams) => {
  return api.post('/doubao/chat', params);
}; 